home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 April: Penguin on DISC / ADC Developer CD (1993-04) (''Penguin On DISC'')_iso / Dev.CD Apr 93.iso / Utilities / MPW Interfaces 7.1 Beta / AIncludes / Sound.a < prev    next >
Encoding:
Text File  |  1992-08-28  |  11.8 KB  |  411 lines  |  [TEXT/MPS ]

  1. ;     File:        Sound.a
  2. ;     Contains:    Definitions for Sound Driver, Sound Output and Input Manager
  3. ;     Copyright:    © 1990-1992 by Apple Computer, Inc., all rights reserved.
  4.  
  5. ;*** Warning: This is an beta version of the Interfaces for Cube-E. 
  6. ;***          Things may change.  Caveat Programmer.
  7.  
  8.  
  9.     IF &TYPE('__INCLUDINGSOUND__') = 'UNDEFINED' THEN
  10. __INCLUDINGSOUND__    SET    1
  11.  
  12.  
  13. ; _______________________________________________________________________
  14. ; Sound Driver
  15. ; _______________________________________________________________________
  16.  
  17. swMode             EQU -1
  18. ftMode             EQU 1
  19. ffMode             EQU 0
  20.  
  21. FFSynthRec        RECORD 0
  22. mode            DS.W 1
  23. count            DS.L 1
  24. waveBytes        DS.B 30001
  25.                 ENDR
  26.  
  27. Tone            RECORD 0
  28. count            DS.W 1
  29. amplitude        DS.W 1
  30. duration        DS.W 1
  31. toneRecSize        EQU *
  32.                 ENDR
  33.  
  34. SWSynthRec        RECORD 0
  35. mode            DS.W 1
  36. triplets        DS.B 5001*Tone.toneRecSize
  37.                 ENDR
  38.  
  39. FTSoundRec        RECORD 0
  40. duration        DS.W 1
  41. sound1Rate        DS.L 1
  42. sound1Phase        DS.L 1
  43. sound2Rate        DS.L 1
  44. sound2Phase        DS.L 1
  45. sound3Rate        DS.L 1
  46. sound3Phase        DS.L 1
  47. sound4Rate        DS.L 1
  48. sound4Phase        DS.L 1
  49. sound1Wave        DS.L 1
  50. sound2Wave        DS.L 1
  51. sound3Wave        DS.L 1
  52. sound4Wave        DS.L 1
  53.                 ENDR
  54.  
  55. FTSynthRec        RECORD 0
  56. mode            DS.W 1
  57. sndRec            DS.L 1
  58.                 ENDR
  59. ; _______________________________________________________________________
  60. ; Sound Manager constants
  61. ; _______________________________________________________________________
  62.  
  63. synthCodeRsrc             EQU 'snth'
  64. soundListRsrc             EQU 'snd '
  65.  
  66. rate22khz                EQU $56EE8BA3        ; 22254.54545
  67. rate11khz                EQU $2B7745D1        ; 11127.27273
  68.  
  69. ; synthesizer numbers for SndNewChannel
  70.  
  71. squareWaveSynth         EQU 1            ; square wave synthesizer
  72. waveTableSynth             EQU 3             ; wave table synthesizer
  73. sampledSynth             EQU 5            ; sampled sound synthesizer
  74.  
  75. ; Command Numbers
  76.  
  77. nullCmd                 EQU 0
  78. initCmd                 EQU 1
  79. freeCmd                 EQU 2
  80. quietCmd                 EQU 3
  81. flushCmd                 EQU 4
  82. reInitCmd                 EQU 5
  83.  
  84. waitCmd                 EQU 10
  85. pauseCmd                 EQU 11
  86. resumeCmd                 EQU 12
  87. callBackCmd             EQU 13
  88. syncCmd                 EQU 14
  89. emptyCmd                 EQU 15
  90.  
  91. tickleCmd                 EQU 20
  92. requestNextCmd             EQU 21
  93. howOftenCmd             EQU 22
  94. wakeUpCmd                 EQU 23
  95. availableCmd             EQU 24
  96. versionCmd                 EQU 25
  97. totalLoadCmd             EQU 26
  98. loadCmd                 EQU 27
  99.  
  100. scaleCmd                 EQU 30
  101. tempoCmd                 EQU 31
  102.  
  103. freqDurationCmd         EQU 40
  104. restCmd                 EQU 41
  105. freqCmd                 EQU 42
  106. ampCmd                     EQU 43
  107. timbreCmd                 EQU 44
  108. getAmpCmd                EQU 45
  109. waveTableCmd             EQU 60
  110. phaseCmd                 EQU 61
  111.  
  112. soundCmd                 EQU 80
  113. bufferCmd                 EQU 81
  114. rateCmd                 EQU 82
  115. continueCmd             EQU 83
  116. doubleBufferCmd         EQU 84
  117. getRateCmd                 EQU 85
  118.  
  119. sizeCmd                 EQU 90
  120. convertCmd                 EQU 91
  121.  
  122. stdQLength                 EQU 128
  123. dataOffsetFlag             EQU $8000
  124.  
  125. waveInitChannelMask        EQU $07
  126. waveInitChannel0        EQU $04
  127. waveInitChannel1        EQU $05
  128. waveInitChannel2        EQU $06
  129. waveInitChannel3        EQU $07
  130.  
  131. ; channel initialization parameters
  132.  
  133. initPanMask                EQU $0003        ; mask for right/left pan values
  134. initSRateMask             EQU $0030        ; mask for sample rate values
  135. initStereoMask             EQU $00C0        ; mask for mono/stereo values
  136. initCompMask            EQU $FF00        ; mask for compression IDs
  137.  
  138. initChanLeft             EQU $0002        ; left stereo channel
  139. initChanRight             EQU $0003        ; right stereo channel
  140. initSRate22k             EQU $0020        ; 22k sampling rate
  141. initMono                 EQU $0080        ; monophonic channel
  142. initStereo                 EQU $00C0        ; stereo channel
  143. initNoInterp             EQU $0004        ; no linear interpolation
  144. initNoDrop                EQU $0008        ; no drop-sample conversion
  145. initMACE3                 EQU $0300        ; MACE 3:1
  146. initMACE6                 EQU $0400        ; MACE 6:1
  147.  
  148. initChan0                 EQU $0004        ; channel 0 - wave table only
  149. initChan1                 EQU $0005        ; channel 1 - wave table only
  150. initChan2                 EQU $0006        ; channel 2 - wave table only
  151. initChan3                 EQU $0007        ; channel 3 - wave table only
  152.  
  153. stdSH                     EQU $0
  154. extSH                     EQU $FF
  155. cmpSH                     EQU $FE
  156.  
  157. notCompressed             EQU 0
  158. twoToOne                 EQU 1
  159. eightToThree             EQU 2
  160. threeToOne                 EQU 3
  161. sixToOne                 EQU 4
  162.  
  163. outsideCmpSH             EQU 0
  164. insideCmpSH             EQU 1
  165. aceSuccess                 EQU 0
  166. aceMemFull                 EQU 1
  167. aceNilBlock             EQU 2
  168. aceBadComp                 EQU 3
  169. aceBadEncode             EQU 4
  170. aceBadDest                 EQU 5
  171. aceBadCmd                 EQU 6
  172. sixToOnePacketSize         EQU 8
  173. threeToOnePacketSize     EQU 16
  174. stateBlockSize             EQU 64
  175. leftOverBlockSize         EQU 32
  176.  
  177. firstSoundFormat         EQU 1
  178. secondSoundFormat         EQU 2
  179.  
  180. dbBufferReady             EQU $00000001
  181. dbLastBuffer             EQU $00000004
  182.  
  183. sysBeepDisable            EQU $0000
  184. sysBeepEnable            EQU $0001
  185.  
  186. unitTypeNoSelection        EQU $FFFF
  187. unitTypeSeconds            EQU $0000
  188.  
  189.  
  190. noneCompType            EQU 'NONE'        ; use no compression on samples
  191. MACE3CompType            EQU 'MAC3'        ; use MACE 3:1 compression on samples
  192. MACE6CompType            EQU 'MAC6'        ; use MACE 6:1 compression on samples
  193.  
  194.  
  195. ; _______________________________________________________________________
  196. ; Sound Manager structures
  197. ; _______________________________________________________________________
  198.  
  199. SndCommand            RECORD 0
  200. cmd                   DS.W 1             ; INTEGER
  201. param1                DS.W 1             ; INTEGER
  202. param2                DS.L 1             ; LONGINT
  203. sndCSize              EQU *             ; size of SndCommand
  204.                       ENDR
  205.  
  206. SndChannel            RECORD 0
  207. nextChan              DS.L 1             ; ^SndChannel
  208. firstMod              DS.L 1             ; Ptr
  209. callBack              DS.L 1             ; ProcPtr
  210. userInfo              DS.L 1
  211.  
  212. ; The following is for internal Sound Manager use only.
  213.  
  214. wait                  DS.L 1             ; Time [LONGINT]
  215. cmdInProgress         DS SndCommand 
  216. flags                 DS.W 1             ; INTEGER
  217. qLength               DS.W 1             ; INTEGER
  218. qHead                 DS.W 1             ; INTEGER
  219. qTail                 DS.W 1             ; INTEGER
  220. queue                 DS.B stdQLength*SndCommand.sndCSize
  221. sndChSize             EQU *             ; size of SndChannel
  222.                       ENDR
  223.  
  224. SoundHeader           RECORD 0
  225. samplePtr             DS.L 1             ; Ptr - if NIL then samples are in sampleArea
  226. length                DS.L 1             ; LONGINT
  227. sampleRate            DS.L 1             ; Fixed
  228. loopStart             DS.L 1             ; LONGINT
  229. loopEnd               DS.L 1             ; LONGINT
  230. baseFrequency          DS.W 1             ; INTEGER
  231. sampleArea            EQU     *             ; PACKED ARRAY [0..0] OF Byte
  232.                       ENDR
  233.  
  234. SMStatus            RECORD 0
  235. smMaxCPULoad        DS.W 1
  236. smNumChannels        DS.W 1
  237. smCurCPULoad        DS.W 1
  238.                     ENDR
  239.  
  240. SCStatus            RECORD 0
  241. scStartTime            DS.L 1
  242. scEndTime            DS.L 1
  243. scCurrentTime        DS.L 1
  244. scChannelBusy        DS.B 1
  245. scChannelDisposed    DS.B 1
  246. scChannelPaused        DS.B 1
  247. scUnused            DS.B 1
  248. scChannelAttributes    DS.L 1
  249. scCPULoad            DS.L 1
  250.                     ENDR
  251.  
  252. AudioSelection        RECORD 0
  253. unitType            DS.L 1
  254. selStart            DS.L 1        ; Fixed; 
  255. selEnd                DS.L 1        ; Fixed; 
  256.                     ENDR
  257.  
  258. SndDoubleBuffer        RECORD 0
  259. dbNumFrames            DS.L 1
  260. dbFlags                DS.L 1
  261. dbUserInfo            DS.L 2
  262. dbSoundData            EQU *                        
  263.                     ENDR
  264.  
  265. SndDoubleBufferHeader    RECORD 0
  266. dbhNumChannels            DS.W 1
  267. dbhSampleSize            DS.W 1
  268. dbhCompressionID        DS.W 1
  269. dbhPacketSize            DS.W 1
  270. dbhSampleRate            DS.L 1
  271. dbhBufferPtr            DS.L 2
  272. dbhDoubleBack            DS.L 1
  273. SndDoubleBufferHeaderSz    EQU  *                        
  274.                         ENDR
  275.  
  276. ; _______________________________________________________________________
  277. ; MACE structures
  278. ; _______________________________________________________________________
  279.  
  280.  
  281. LeftOverBlock        RECORD 0
  282. count                DS.L 1
  283. sampleArea            DS.B leftOverBlockSize
  284.                     ENDR
  285.  
  286. CmpSoundHeader         RECORD 0
  287. samplePtr            DS.L 1            ; if NIL then samples are in sampleArea
  288. numChannels            DS.L 1            ; number of channels  mono = 1
  289. sampleRate            DS.L 1            ; sample rate in Apples Fixed point representation
  290. loopStart            DS.L 1            ; loopStart of sound before compression
  291. loopEnd                DS.L 1            ; loopEnd of sound before compression
  292. encode                DS.B 1            ; data structure used ,  stdSH, extSH, or cmpSH
  293. baseFrequency        DS.B 1            ; same meaning as regular SoundHeader
  294. numFrames            DS.L 1            ; length in frames    ( packetFrames or sampleFrames
  295. AIFFSampleRate        DS.B 10            ; IEEE sample rate EXTENDED number
  296. markerChunk            DS.L 1            ; sync track
  297. futureUse1            DS.L 1            ; reserved by Apple
  298. futureUse2            DS.L 1            ; reserved by Apple
  299. stateVars            DS.L 1            ; pointer to State Block
  300. leftOverSamples        DS.L 1            ; used to save truncated samples between compression calls
  301. compressionID        DS.W 1            ; 0 means no compression, non zero means compressionID
  302. packetSize            DS.W 1            ; number of bits in compressed sample packet
  303. snthID                DS.W 1            ; Resource ID of Sound Manager snth that contains NRT C/E
  304. sampleSize            DS.W 1            ; number of bits in non-compressed sample
  305. sampleArea            DS.B 1             ; PACKED ARRAY [0..0] OF Byte
  306.                     align
  307. size                EQU     *             ; size of this entire record
  308.                     ENDR
  309.  
  310. ExtSoundHeader         RECORD 0
  311. samplePtr            DS.L 1            ; if NIL then samples are in sampleArea
  312. numChannels            DS.L 1            ; number of channels  mono = 1
  313. sampleRate            DS.L 1            ; sample rate in Apples Fixed point representation
  314. loopStart            DS.L 1            ; loopStart of sound before compression
  315. loopEnd                DS.L 1            ; loopEnd of sound before compression
  316. encode                DS.B 1            ; data structure used ,  stdSH, extSH, or cmpSH
  317. baseFrequency        DS.B 1            ; same meaning as regular SoundHeader
  318. numFrames            DS.L 1            ; length in total number of frames
  319. AIFFSampleRate        DS.B 10            ; IEEE sample rate
  320. markerChunk            DS.L 1            ; sync track
  321. instrumentChunks    DS.L 1
  322. AESRecording        DS.L 1
  323. sampleSize            DS.W 1            ; number of bits in sample
  324. futureUse1            DS.W 1            ; reserved by Apple
  325. futureUse2            DS.L 1            ; reserved by Apple
  326. futureUse3            DS.L 1            ; reserved by Apple
  327. futureUse4            DS.L 1            ; reserved by Apple
  328. sampleArea            DS.B 1             ; PACKED ARRAY [0..0] OF Byte
  329.                     align
  330. size                EQU     *             ; size of this entire record
  331.                     ENDR
  332.  
  333. ; _______________________________________________________________________
  334. ; Sound Input
  335. ; _______________________________________________________________________
  336.  
  337. siDeviceIsConnected        EQU 1            ; input device is connected and ready for input
  338. siDeviceNotConnected    EQU 0            ; input device is not connected
  339. siDontKnowIfConnected    EQU -1            ; can't tell if input device is connected
  340.  
  341.  
  342. ; Info Selectors for the SPBGetDeviceInfo and SPBSetDeviceInfo calls
  343.  
  344. siDeviceConnected        EQU 'dcon'        ; input device connection status
  345. siAGCOnOff                EQU 'agc '        ; automatic gain control state
  346. siPlayThruOnOff            EQU 'plth'        ; playthrough state
  347. siTwosComplementOnOff    EQU 'twos'        ; two's complement state
  348. siLevelMeterOnOff        EQU 'lmet'        ; level meter state
  349. siRecordingQuality        EQU 'qual'        ; recording quality
  350. siVoxRecordInfo            EQU 'voxr'        ; VOX record parameters
  351. siVoxStopInfo            EQU 'voxs'        ; VOX stop parameters
  352. siNumberChannels        EQU 'chan'        ; current number of channels
  353. siSampleSize            EQU 'ssiz'        ; current sample size
  354. siSampleRate            EQU 'srat'        ; current sample rate
  355. siCompressionType        EQU 'comp'        ; current compression type
  356. siCompressionFactor        EQU 'cmfa'        ; current compression factor
  357. siCompressionHeader        EQU 'cmhd'        ; return compression header
  358. siDeviceName            EQU 'name'        ; input device name
  359. siDeviceIcon            EQU 'icon'        ; input device icon
  360. siDeviceBufferInfo        EQU 'dbin'        ; size of interrupt buffer
  361. siSampleSizeAvailable    EQU 'ssav'        ; sample sizes available
  362. siSampleRateAvailable    EQU 'srav'        ; sample rates available
  363. siCompressionAvailable    EQU 'cmav'        ; compression types available
  364. siChannelAvailable        EQU 'chav'        ; number of channels available
  365. siAsync                    EQU 'asyn'        ; asynchronous capability
  366. siOptionsDialog            EQU 'optd'        ; display options dialog
  367. siContinuous            EQU 'cont'        ; continous recording
  368. siActiveChannels        EQU 'chac'        ; active channels
  369. siActiveLevels            EQU 'lmac'        ; active meter levels
  370. siInputSource            EQU 'sour'        ; input source selector
  371. siInitializeDriver        EQU 'init'        ; reserved for internal use only
  372. siCloseDriver            EQU 'clos'        ; reserved for internal use only
  373. siPauseRecording        EQU 'paus'        ; reserved for internal use only
  374. siUserInterruptProc        EQU 'user'        ; reserved for internal use only
  375.  
  376. ; Quality Selectors for the SndRecord and SndRecordToFile calls
  377.  
  378. siBestQuality            EQU 'best'
  379. siBetterQuality            EQU 'betr'
  380. siGoodQuality            EQU 'good'
  381.  
  382. ; Sound Input Parameter Block (SPB)
  383.  
  384. SInParam            RECORD 0
  385. inRefNum            DS.L 1            ; pointer to Application Reference Block
  386. count                DS.L 1            ; the # of bytes to read
  387. milliseconds        DS.L 1            ; the # of ms of sound to read
  388. bufferLength        DS.L 1            ; length of input buffer
  389. inputBuffer            DS.L 1            ; pointer to input buffer
  390. completionRoutine    DS.L 1            ; procPtr to the user completion routine
  391. interruptRoutine    DS.L 1            ; procPtr to the user interrupt routine
  392. userLong            DS.L 1            ; reserved for user data
  393. error                DS.W 1            ; OSErr will be returned to asynch routines
  394. unused1                DS.L 1            ; reserved for future expansion - must be zero
  395. SInPARAMSize        EQU *            ; size of SInParam
  396.                     ENDR
  397.  
  398.  
  399.     ENDIF    ; ...already included